﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" ValidateRequest="false"
    AutoEventWireup="true" CodeFile="Class.aspx.cs" Inherits="Admin_Class" Title="Manage Class - ILE Admin" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
    TagPrefix="cc2" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Register TagPrefix="uc" TagName="UpdateProgress" Src="~/UserControls/UpdateProgress.ascx" %>
<%@ Register TagPrefix="uc" TagName="ModalPopupMessage" Src="~/UserControls/ModalPopupMessage.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">
    <uc:UpdateProgress ID="updateProgress" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <uc:ModalPopupMessage ID="ModalPopupMessage" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <h1>
        Manage Class</h1>
    <br />
    <asp:Button ID="btnOpenAddClass" runat="server" Text="Add Class" Width="153px" OnClick="btnOpenAddClass_Click" />
    &nbsp;&nbsp;
    <asp:Button ID="btnOpenEditClass" runat="server" Text="Edit Class" Width="160px"
        OnClick="btnOpenEditClass_Click" />
    <br />
    <br />
    <asp:MultiView ID="MultiViewClass" runat="server" Visible="false" ActiveViewIndex="0">
        <asp:View ID="ViewAddClass" runat="server">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <h3>
                        Add Class</h3>
                    <table>
                        <tr>
                            <td class="tableLeftHeader">
                                Class Sections: *
                            </td>
                            <td class="tableItem">
                                <asp:ListBox ID="lstboxSections" runat="server" SelectionMode="Multiple" Rows="8"
                                    Width="80px" ValidationGroup="AddClass"></asp:ListBox>
                                <br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="lstboxSections"
                                    ErrorMessage="* Please select at least one section." ValidationGroup="AddClass"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="tableLeftHeader">
                                Class Title: *
                            </td>
                            <td class="tableItem">
                                <asp:TextBox ID="txtClassTitle" runat="server" Width="230px" ValidationGroup="AddClass"
                                    MaxLength="50" />
                                &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtClassTitle"
                                    ErrorMessage="* Class Title is required." ValidationGroup="AddClass"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="tableLeftHeader">
                                Class Subtitle: *
                            </td>
                            <td class="tableItem">
                                <asp:TextBox ID="txtClassSubtitle" runat="server" Width="200px" ValidationGroup="AddClass"
                                    MaxLength="50" />
                                &nbsp;
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="* Class Subtitle is required."
                                    ControlToValidate="txtClassSubtitle" ValidationGroup="AddClass"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="tableLeftHeader">
                                Introduction:
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <FCKeditorV2:FCKeditor ID="txtIntroduction" runat="server" BasePath="~/fckeditor/"
                                    ToolbarSet="ILE_Admin" HtmlEncodeOutput="false" Width="550" Height="350">
                                </FCKeditorV2:FCKeditor>
                            </td>
                        </tr>
                        <tr>
                            <td class="tableLeftHeader">
                                Is Enabled?: *
                            </td>
                            <td>
                                <!-- *SteveMsg -->
                                <asp:CheckBox ID="chkboxIsEnabled" runat="server" Text="(Overrides class section settings when disabled.)"
                                    Checked="True" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <br />
                                <div style="width: 550px; text-align: center;">
                                    <asp:Button ID="btnAddClass" runat="server" Text="Add Class" Width="250px" OnClick="btnAddClass_Click"
                                        ValidationGroup="AddClass" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID="btnAddClass" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:View>
        <asp:View ID="ViewEditClass" runat="server">
            <h3>
                Edit Class</h3>
            <asp:ObjectDataSource ID="ObjectDataSourceClasses" runat="server" InsertMethod="InsertCourseSection"
                OldValuesParameterFormatString="original_{0}" SelectMethod="GetCourses" TypeName="ClassBLL">
                <InsertParameters>
                    <asp:Parameter Name="courseID" Type="Int32" />
                    <asp:Parameter Name="sectionNumber" Type="Int32" />
                    <asp:Parameter Name="useSectionInfo" Type="Boolean" />
                    <asp:Parameter Name="subtitle" Type="String" />
                    <asp:Parameter Name="introduction" Type="String" />
                    <asp:Parameter Name="classTime" Type="String" />
                    <asp:Parameter Name="isEnabled" Type="Boolean" />
                </InsertParameters>
            </asp:ObjectDataSource>
            <asp:GridView ID="GridViewClasses" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CourseID" DataSourceID="ObjectDataSourceClasses"
                ForeColor="#333333" GridLines="None" Width="550px" EmptyDataText="<div class='GridViewNoData'>No Data</div>"
                OnSelectedIndexChanged="GridViewClasses_SelectedIndexChanged">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="CourseID" HeaderText="ID" SortExpression="CourseID" InsertVisible="False"
                        ReadOnly="True" />
                    <asp:BoundField DataField="Title" HeaderText="Class Title" SortExpression="Title">
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:CheckBoxField DataField="IsEnabled" HeaderText="Is Enabled?" SortExpression="IsEnabled">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:CheckBoxField>
                </Columns>
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
            <br />
            <ajaxToolkit:Accordion ID="AccordionEditClass" runat="server" SelectedIndex="0" AutoSize="None"
                FadeTransitions="true" TransitionDuration="200" FramesPerSecond="30" RequireOpenedPane="true"
                SuppressHeaderPostbacks="true" Visible="false" HeaderCssClass="accordionHeader"
                HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent">
                <Panes>
                    <ajaxToolkit:AccordionPane ID="AccordionPane1231" runat="server">
                        <Header>
                            Edit Course Default Information</Header>
                        <Content>
                            <table>
                                <tr>
                                    <td class="tableLeftHeader">
                                        Class Title:
                                    </td>
                                    <td class="tableItem">
                                        <asp:TextBox ID="txtEditClassTitle" runat="server" Width="230px" ValidationGroup="EditClass"
                                            MaxLength="50" />
                                        &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtEditClassTitle"
                                            ErrorMessage="* Class Title is required." ValidationGroup="EditClass"></asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="tableLeftHeader">
                                        Class Subtitle:
                                    </td>
                                    <td class="tableItem">
                                        <asp:TextBox ID="txtEditClassSubtitle" runat="server" Width="200px" ValidationGroup="EditClass"
                                            MaxLength="50" />
                                        &nbsp;
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="* Class Subtitle is required."
                                            ControlToValidate="txtEditClassSubtitle" ValidationGroup="EditClass" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <span style="font-weight: bold;">Introduction:</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <FCKeditorV2:FCKeditor ID="txtEditIntroduction" runat="server" BasePath="~/fckeditor/"
                                            ToolbarSet="ILE_Admin" HtmlEncodeOutput="false" Width="550" Height="350">
                                        </FCKeditorV2:FCKeditor>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:CheckBox ID="chkEditIsEnabled" runat="server" Text="Is Enabled? (Overrides class section settings)" />
                                        <br />
                                        <br />
                                        <div style="width: 550px; text-align: center;">
                                            <asp:Button ID="btnEditClass" runat="server" Text="Edit Class" Width="250" OnClick="btnEditClass_Click"
                                                ValidationGroup="EditClass" />&nbsp;&nbsp;&nbsp;&nbsp;
                                            <asp:Button ID="btnDeleteClass" runat="server" Text="Delete Class" Width="150" />
                                            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground"
                                                TargetControlID="btnDeleteClass" PopupControlID="PanelConfirmDeleteClass" CancelControlID="btnModalPopupConfirmDeleteClassCancel"
                                                DropShadow="true" PopupDragHandleControlID="PanelModalPopupConfirmDeleteClassTitle">
                                            </ajaxToolkit:ModalPopupExtender>
                                            <asp:Panel ID="PanelConfirmDeleteClass" runat="server" Width="500" CssClass="modalPopup"
                                                Style="display: none">
                                                <asp:Panel ID="PanelModalPopupConfirmDeleteClassTitle" runat="server">
                                                    <div class="modalPopupTitle">
                                                        Confirm Delete Class
                                                    </div>
                                                </asp:Panel>
                                                <div class="modalPopupContext">
                                                    <table>
                                                        <tr>
                                                            <td style="padding: 0px 20px 0px 10px;">
                                                                <img alt="Question" src="../Images/QuestionIcon.jpg" width="60" height="60" />
                                                            </td>
                                                            <td>
                                                                <span style="font-weight: bold; font-size: medium;">Are you sure you want to delete
                                                                    this class? </span>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <br />
                                                </div>
                                                <div class="modalPopupBottom">
                                                    <asp:Button ID="btnModalPopupConfirmDeleteClassOK" runat="server" Text="OK" OnClick="btnModalPopupConfirmDeleteClassOK_Click" />
                                                    &nbsp;&nbsp;&nbsp;
                                                    <asp:Button ID="btnModalPopupConfirmDeleteClassCancel" runat="server" Width="150"
                                                        Text="Cancel" />
                                                </div>
                                            </asp:Panel>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </Content>
                    </ajaxToolkit:AccordionPane>
                    <ajaxToolkit:AccordionPane ID="AccordionPane1232" runat="server">
                        <Header>
                            Edit Course Sections</Header>
                        <Content>
                            <asp:Button ID="btnAddOrRemoveSections" runat="server" Text="Add/Remove Sections"
                                Width="200" />
                            <br />
                            <br />
                            <asp:Panel ID="PanelModalPopupAddOrRemoveSections" runat="server" Width="500" CssClass="modalPopup"
                                Style="display: none">
                                <asp:Panel ID="PanelModalPopupTitle" runat="server">
                                    <div class="modalPopupTitle">
                                        Add/Remove Sections
                                    </div>
                                </asp:Panel>
                                <div class="modalPopupContext">
                                    <table style="width: 480px;">
                                        <tr>
                                            <td class="tableTopHeader">
                                                Available Sections
                                            </td>
                                            <td class="tableTopHeader">
                                                Current Sections
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:ListBox ID="lstboxAvailableSections" runat="server" Width="100" Height="150"
                                                    SelectionMode="Multiple" />
                                                <br />
                                                <br />
                                                <asp:Button ID="btnAddSections" runat="server" Text="Add Sections" Width="150" OnClick="btnAddSections_Click" />
                                                <%--<br />
                                                <asp:CheckBox ID="chkboxAddSectionsInheritSettings" runat="server" Text="Inherit Class Settings" />--%>
                                            </td>
                                            <td>
                                                <asp:ListBox ID="lstboxCurrentSections" runat="server" Width="100" Height="150" SelectionMode="Multiple" />
                                                <br />
                                                <br />
                                                <asp:Button ID="btnRemoveSections" runat="server" Text="Remove Sections" Width="150"
                                                    OnClick="btnRemoveSections_Click" />
                                            </td>
                                        </tr>
                                    </table>
                                    <br />
                                </div>
                                <div class="modalPopupBottom">
                                    <asp:Button ID="btnAddOrRemoveSectionsDone" runat="server" Text="Done" />
                                </div>
                            </asp:Panel>
                            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
                                TargetControlID="btnAddOrRemoveSections" PopupControlID="PanelModalPopupAddOrRemoveSections"
                                PopupDragHandleControlID="PanelModalPopupTitle" Drag="true" CancelControlID="btnAddOrRemoveSectionsDone"
                                DropShadow="true" />
                            <asp:ObjectDataSource ID="ObjectDataSourceSectionsByCourseID" runat="server" InsertMethod="InsertCourseSection"
                                OldValuesParameterFormatString="original_{0}" SelectMethod="GetSectionsByCourseID"
                                TypeName="ClassBLL" UpdateMethod="UpdateCourse">
                                <UpdateParameters>
                                    <asp:Parameter Name="Title" Type="String" />
                                    <asp:Parameter Name="Subtitle" Type="String" />
                                    <asp:Parameter Name="Introduction" Type="String" />
                                    <asp:Parameter Name="IsEnabled" Type="Boolean" />
                                    <asp:Parameter Name="CourseID" Type="Int32" />
                                </UpdateParameters>
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="GridViewClasses" Name="CourseID" PropertyName="SelectedValue"
                                        Type="Int32" />
                                    <asp:Parameter DefaultValue="False" Name="GetEnabled" Type="Boolean" />
                                </SelectParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="courseID" Type="Int32" />
                                    <asp:Parameter Name="sectionNumber" Type="Int32" />
                                    <asp:Parameter Name="useSectionInfo" Type="Boolean" />
                                    <asp:Parameter Name="subtitle" Type="String" />
                                    <asp:Parameter Name="introduction" Type="String" />
                                    <asp:Parameter Name="classTime" Type="String" />
                                    <asp:Parameter Name="isEnabled" Type="Boolean" />
                                </InsertParameters>
                            </asp:ObjectDataSource>
                            <asp:GridView ID="GridViewEditSectionList" runat="server" AllowPaging="True" AllowSorting="True"
                                AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CourseID,SectionNumber"
                                DataSourceID="ObjectDataSourceSectionsByCourseID" ForeColor="#333333" GridLines="None"
                                Width="550px" EmptyDataText="<div class='GridViewNoData'>No Data</div>" OnSelectedIndexChanged="GridViewEditSectionList_SelectedIndexChanged">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <Columns>
                                    <asp:CommandField ShowSelectButton="True" />
                                    <asp:BoundField DataField="SectionNumber" HeaderText="Sect. #" ReadOnly="True" SortExpression="SectionNumber">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:CheckBoxField DataField="UseSectionInfo" HeaderText="Use Sect. Info?" SortExpression="UseSectionInfo">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:CheckBoxField>
                                    <asp:BoundField DataField="ClassTime" HeaderText="Class Time" SortExpression="ClassTime">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:CheckBoxField DataField="IsEnabled" HeaderText="Is Enabled?" SortExpression="IsEnabled">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:CheckBoxField>
                                </Columns>
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <EditRowStyle BackColor="#999999" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                            <br />
                            <asp:Panel ID="PanelEditSection" runat="server" Visible="false">
                                <table>
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Use Section Info:
                                        </td>
                                        <td class="tableItem">
                                            <asp:CheckBox ID="chkEditUseSectionInfo" runat="server" Text="" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Alternative Class Subtitle:
                                        </td>
                                        <td class="tableItem">
                                            <asp:TextBox ID="txtEditSectionSubtitle" runat="server" Width="200px" ValidationGroup="EditSection"
                                                MaxLength="50" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tableLeftHeader">
                                            Class Time:
                                        </td>
                                        <td class="tableItem">
                                            <asp:TextBox ID="txtEditSectionClassTime" runat="server" Width="150px" ValidationGroup="EditSection"  MaxLength="30" ></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <span style="font-weight: bold;">Introduction:</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <FCKeditorV2:FCKeditor ID="txtEditSectionIntroduction" runat="server" BasePath="~/fckeditor/"
                                                ToolbarSet="ILE_Admin" HtmlEncodeOutput="false" Width="550" Height="350">
                                            </FCKeditorV2:FCKeditor>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:CheckBox ID="chkEditSectionIsEnabled" runat="server" Text="Is This Section Enabled?" />
                                            <br />
                                            <br />
                                            <div style="width: 550px; text-align: center;">
                                                <asp:Button ID="btnEditSection" runat="server" Text="Edit Section" Width="250px"
                                                    ValidationGroup="EditSection" OnClick="btnEditSection_Click" />
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </Content>
                    </ajaxToolkit:AccordionPane>
                </Panes>
            </ajaxToolkit:Accordion>
        </asp:View>
    </asp:MultiView>
</asp:Content>
